package com.example.springpethospital.common.model;

import javax.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
public class PagingParam {

    public static final PagingParam DEFAULT_PAGING_PARAM = new PagingParam(0, 1000);

    @NotNull(message = "分页参数start不可为空")
    private Integer start;

    @NotNull(message = "分页参数length不可为空")
    private Integer length;

    public void setIfNull() {
        if (start == null || length == null) {
            start = 0;
            length = 10;
        }
    }


}
